package com.xxx.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: xxx
 * @Date: 2023/1/9 21:16
 * @Description: RabbitMq配置类-topic模式
 */
@Configuration
public class RabbitMQTopicConfig {
    
    private static final String QUEUE01="queue_topic01";
    private static final String QUEUE02="queue_topic02";
    private static final String EXCHANGE="topicExchange";
    private static final String ROUTINGKEY01="#.queue.#";
    private static final String ROUTINGKEY02="*.queue.#";

    /**
     * 准备队列
     */
    @Bean
    public Queue queue0001(){
        return new Queue(QUEUE01);
    }

    /**
     * 准备队列
     */
    @Bean
    public Queue queue0002(){
        return new Queue(QUEUE02);
    }

    /**
     * 准备交换机
     */
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(EXCHANGE);
    }

    /**
     * 绑定
     */
    @Bean
    public Binding binding0001(){
        return BindingBuilder.bind(queue0001()).to(topicExchange()).with(ROUTINGKEY01);
    }

    /**
     * 绑定
     */
    @Bean
    public Binding binding0002(){
        return BindingBuilder.bind(queue0002()).to(topicExchange()).with(ROUTINGKEY02);
    }

    


}
